<?php
// +----------------------------------------------------------------------
// | HkCms 用户验证规则
// +----------------------------------------------------------------------
// | Copyright (c) 2012-2019 http://www.hkcms.cn, All rights reserved.
// +----------------------------------------------------------------------
// | Author: 广州恒企教育科技有限公司 <admin@hkcms.cn>
// +----------------------------------------------------------------------
namespace app\content\validate;

use think\Validate;

class Model extends Validate
{

    protected $rule = [
        'name' => 'require|unique:model',
        // 'tablename' => 'require|/^[a-zwd_]+$/i|unique:model|checkTablesql|checkTablename',
        'tablename' => 'require|/^[a-zwd_]+$/i|unique:model',
        
    ];

    protected $message  =   [
        'name.require' => '模型名称不能为空！',
        'name.unique' => '模型名已经存在',
        'tablename.require' => '表名不能为空！',
        'tablename./^[a-zwd_]+$/i' => '模型表键名只支持英文！',
        'name.unique:model' => '该模型名称已经存在！',
        'tablename.unique:model' => '该表名已经存在！',
        'tablename.checkTablesql' => '创建模型所需要的SQL文件丢失，创建失败！',
        'tablename.checkTablename' => '该表名是系统保留或者已经存在，不允许创建！',
    ];

    protected $scene = [
        'edit'  =>  ['name' => 'require' , 'tablename' => 'require|/^[a-zwd_]+$/i'],
    ];
}